import { currUserRoles } from '@/store'
import { ADMIN_ID } from '@/constant'
import { useRecoilValue } from 'recoil'
import { omit } from 'lodash-es'
import React from 'react'

const Index = (props) => {
  const currentRole = useRecoilValue(currUserRoles)
  const { children } = props

  if (currentRole.current.actorType === ADMIN_ID) {
    return React.cloneElement(children, { ...omit(props, ['children']) })
  }
  return null
}

export default Index
